<?php 
   /**
    * archives 文章归档
    * 
    * @package custom 
    */ 
$this->need('header.php');?>
	<style type="text/css">h2{font-style:italic}h3{font-size:20px;line-height:26px}#archives{padding-top:20px;}#archives ul li{line-height:24px;background: #F9F9F9;border-bottom: 2px solid #EEE;margin: 0 10px 10px 0;padding: 5px;}</style>
<div id="main">
	<div id="postlist">
		<span class="arch-titlecon-time">Archives</span>
		<h2>归档页面</h2>
		<span id="control" style="cursor:pointer;color:#666666;text-shadow:0 0 2px #66CD00;float: right;font-size: 15px;">全部展开/收起</span>
		<?php $this->widget('Widget_Contents_Post_Recent', 'pageSize=10000')->to($archives);
			$year=0; $mon=0; $i=0; $j=0;
			$output = '<div id="archives">';
			while($archives->next()):
			$year_tmp = date('Y',$archives->created);
             $mon_tmp = date('m',$archives->created);
			 //var_dump($year_tmp);
             $y=$year; $m=$mon;
             if ($mon != $mon_tmp && $mon > 0) $output .= '</ul></li>';
             if ($year != $year_tmp && $year > 0) $output .= '</ul>';
             if ($year != $year_tmp) {
                 $year = $year_tmp;
                 $output .= '<h3 class="al_year">'. $year .' 年</h3><ul class="al_mon_list">'; //输出年份
             }
             if ($mon != $mon_tmp) {
                 $mon = $mon_tmp;
                 $output .= '<li><span class="al_mon">'. $mon .' 月</span><ul class="al_post_list">'; //输出月份
             }
             $output .= '<li>'.date('d日: ',$archives->created).'<a href="'.$archives->permalink .'">'. $archives->title .'</a> <em>('. $archives->commentsNum.')</em></li>'; //输出文章日期和标题
		endwhile;
		$output .= '</ul></li></ul></div>';
		echo $output;
		?>
		
	</div>
</div>
<?php $this->need('sidebar.php'); ?>
<?php $this->need('footer.php'); ?>
<!--这里开始jQuery-->
<script type="text/javascript">
	jQuery(function($){
		$('#archives ul li ul:gt(0)').hide();//第0和1 列默认显示，其他默认隐藏
		$('#archives ul li span').click(function() {//点击标题动作
		$('#archives ul li ul').slideUp(300);//展开选择列
		$(this).next('ul').slideDown(500);//缩放同级其他元素
		});
		//一下是全局的操作
		$('#control').toggle(
		function(){
			$('#archives ul li ul').slideDown();
		},
		function(){
			$('#archives ul li ul').slideUp();
		});	
	});	
</script>